package br.com.conhecimento.ejb.server.util;

import org.apache.commons.lang.exception.ExceptionUtils;
import org.springframework.mail.MailSender;
import org.springframework.mail.SimpleMailMessage;

public class Utils {

    public static void sendMailException(SimpleMailMessage alertMailMessage, MailSender mailSender, String title, Exception e) {	
		SimpleMailMessage mailMessage = new SimpleMailMessage(alertMailMessage);
		mailMessage.setSubject(String.format(alertMailMessage.getSubject(), "EXCEPTION: " + title));
		mailMessage.setText(String.format(alertMailMessage.getText(), title + "\n" + e.getMessage(), ExceptionUtils.getStackTrace(e)));
		mailSender.send(mailMessage);
    }
    
}
